package excise04_afterclass;
//输出0-100以内的偶数

class PrintEvenNum extends Thread{
    @Override
    public void run(){
        synchronized(PrintEvenNum.class) {
            for (int i = 0; i < 100; i++) {
                if (i % 2 == 0) {
                    System.out.println(Thread.currentThread().getName() + ":" + i);
                }
            }
        }
    }
}
public class Test1{
    public static void main(String[] args){
        PrintEvenNum p1 = new PrintEvenNum();
        p1.setName("线程一");
        p1.start();

        PrintEvenNum p2 = new PrintEvenNum();
        p2.setName("线程二");
        p2.start();
    }
}
